package com.example.last.service;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.example.last.dao.PaperDao;
import com.example.last.dao.QuestionsDao;
import com.example.last.dao.TypeDao;
import com.example.last.entity.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PaperService {
    @Resource
    private PaperDao paperDao;

    public PageInfo<Paper> findBySearch(@Param("params") Params params){
        //开启分页查询
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        List<Paper> list =  paperDao.findBySearch(params);
        return PageInfo.of(list);
    }


    public void add(Paper paper) {
        paperDao.add(paper);
    }

    public void update(Paper paper) {
        paperDao.update(paper);
    }

    public void delete(Integer id) {
        paperDao.delete(id);
    }

    public List<Paper> findAll() {
        return paperDao.findAll();
    }

    public List<Questions> findQuestionById(Integer id) {
        return paperDao.findQuestionById(id);
    }
}
